//
//  SaoFinishController.m
//  CreateMyCode
//
//  Created by zhibao on 2024/12/17.
//

#import "SaoFinishController.h"

@interface SaoFinishController (){
    UILabel *contentLabel;
}

@end

@implementation SaoFinishController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.gk_navTitle = LocalizedString(@"扫描结果");
    contentLabel = [UILabel new];
    contentLabel.numberOfLines = 0;
    contentLabel.textColor = MyColor(@"333333");
    contentLabel.font = MY_SCALE_RegularFONT(15);
    NSString *tempStr = [self.title stringByReplacingOccurrencesOfString:@"&!&" withString:@"\n"];
    contentLabel.text = self.content;
    contentLabel.textAlignment = NSTextAlignmentCenter;
    contentLabel.lineBreakMode = NSLineBreakByWordWrapping;
    [self.view addSubview:contentLabel];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.width.mas_equalTo(300);
    }];
    
    UIImageView *iconImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"com_icon"]];
    [self.view addSubview:iconImgView];
    [iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(pixw(80));
        make.centerX.equalTo(contentLabel);
        make.bottom.equalTo(contentLabel.mas_top).offset(pixw((-30)));
    }];
    
    UIButton *cotiueBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    cotiueBtn.backgroundColor = MYBlue;
    cotiueBtn.layer.cornerRadius = 22;
    [cotiueBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    [cotiueBtn setTitle:LocalizedString(@"复制") forState:UIControlStateNormal];
    cotiueBtn.titleLabel.font = MY_SCALE_SemiboldFONT(16);
    [cotiueBtn addTarget:self action:@selector(copyString) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:cotiueBtn];
    [cotiueBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(contentLabel);
        make.top.equalTo(contentLabel.mas_bottom).offset(20);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(40);
    }];
}

-(void)copyString{
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = contentLabel.text;
    [QMUITips showSucceed:LocalizedString(@"复制成功")];

}
@end
